#{extends 'Products/edit.html' /}

<div id="crudShow" class="${type.name}">
	
	<h2 id="crudShowTitle">&{'crud.show.title', type.modelName}</h2>
	
	<div class="objectForm">
	#{form action:@save(object._key()), enctype:'multipart/form-data'}
		#{crud.form fields:['name','urlKey','productTypes','priority','showInHomepage','summary','overview','specifications','dentalsellerUrl','amazonUrl','ebayUrl','brochure','images','homepageBigImage','homepageSmallImage','detailImage']}
			#{crud.custom 'productTypes'}
				 <label for="productTypes">
		            &{'productTypes'}
		        </label>
		      
		        %{
			        types = '';
			        for(i=0;i<object.productTypes.size();i++){
			        	if(i>0) types+=',';
			        	types +=object.productTypes[i].name;
			        }
		       	}%
		       	<input type="text" id="selectedProductTypeNames" value="${types}" readonly="readonly">
		       	<input type="hidden" id="productTypeFiledName" value="${fieldName}"/>
				<span id="selectedProductTypeIds">
				#{list items:object.productTypes,as:'ptype'}
					<input type='hidden' name='${fieldName}' value='${ptype.id}'/>
				#{/list}
				</span>
			#{/crud.custom}
			#{crud.custom 'images'}
				 <label for="images">
		            &{'images'}
		        </label>
				<span id="images">
					<div id="productImages">
						#{list items:object.images,as:'image'}
							<img src='${play.configuration['attachments.download.prefix']+image}' style='margin:5px;border:1px solid #cccccc;height:50px;' title='${image}' >
							<input type='hidden' name='object.images' value='${image}'>
						#{/list}
					</div>
				</span>
				<span class="crudHelp">
					<input id="imagesUpload" name="imagesUpload" type="file" />
				</span>
			#{/crud.custom}
			#{crud.custom 'homepageBigImage'}
		        #{uploadImage name:'homepageBigImage',value:object.homepageBigImage /}
			#{/crud.custom}
			#{crud.custom 'homepageSmallImage'}
				#{uploadImage name:'homepageSmallImage',value:object.homepageSmallImage /}
			#{/crud.custom}
			#{crud.custom 'detailImage'}
				#{uploadImage name:'detailImage',value:object.detailImage /}
			#{/crud.custom}
			#{crud.custom 'brochure'}
				#{uploadFile name:'brochure',value:object.brochure/}
			#{/crud.custom}
		#{/crud.form}
		<p class="crudButtons">
			<input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
			<input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
		</p>
	#{/form}
	</div>
	
	#{form @delete(object._key())}
		<p class="crudDelete">
			<input type="submit" value="&{'crud.delete', type.modelName}" />
		</p>
	#{/form}

</div>